package com.tobeface.wechat.message.payload;

import com.tobeface.modules.lang.Requires;
import com.tobeface.wechat.message.WeChatMessageBuilder;
import com.tobeface.wechat.message.WeChatMessagePayloads;
import com.tobeface.wechat.message.WeChatMessageTypes;

import java.util.Map;

/**
 * @author loudyn
 */
public class LocationMessagePayloadBuilder extends AbstractMessagePayloadBuilder {

    private String xpoint;
    private String ypoint;
    private String scale;
    private String label;

    /**
     * @param parent
     */
    public LocationMessagePayloadBuilder(WeChatMessageBuilder parent) {
        super(parent);
    }

    /**
     * @param ypoint
     * @return
     */
    public LocationMessagePayloadBuilder ypoint(String ypoint) {
        Requires.hasText(ypoint, "Ypoint must not be empty or null!");
        this.ypoint = ypoint;
        return this;
    }

    /**
     * @param xpoint
     * @return
     */
    public LocationMessagePayloadBuilder xpoint(String xpoint) {
        this.xpoint = xpoint;
        return this;
    }

    /**
     * @param scale
     * @return
     */
    public LocationMessagePayloadBuilder scale(String scale) {
        this.scale = scale;
        return this;
    }

    /**
     * @param label
     * @return
     */
    public LocationMessagePayloadBuilder label(String label) {
        this.label = label;
        return this;
    }

    @Override
    protected void configPayloads(Map<String, Object> payloads) {
        payloads.put(WeChatMessagePayloads.MSGTYPE_PAYLOAD, WeChatMessageTypes.LOCATION);
        payloads.put(WeChatMessagePayloads.LOC_XPOINT_PAYLOAD, xpoint);
        payloads.put(WeChatMessagePayloads.LOC_YPOINT_PAYLOAD, ypoint);
        payloads.put(WeChatMessagePayloads.LOC_SCALE, scale);
        payloads.put(WeChatMessagePayloads.LOC_LABEL, label);
    }
}
